import React from 'react'
import { Switch } from 'antd'
import { SchemaForm, Item, Submit, Observer, mapProps } from '@amazebird/antd-schema-form'

const MySwitch = mapProps(Switch, { from: 'value', to: 'checked' })
console.info(Switch, Switch.prototype instanceof React.Component)
const schema = {
  show: {
    label: '是否显示输入框',
    component: MySwitch
  },
  input: {
    label: '输入框',
    component: 'Input',
    visible: Observer({
      watch: 'show',
      action: (show) => show
    })
  }
}

function Visible() {
  return (
    <SchemaForm schema={schema}>
      <Item field="show" />
      <Item field="input" />
      <Submit onFinish={(data) => { console.info(data) }} />
    </SchemaForm>
  )
}

export default Visible
